package com.zhongfl.crm.model.boss;

import com.zhongfl.crm.enums.boss.OrderStatus;
import com.zhongfl.crm.enums.boss.WorkOrderStatus;
import com.zhongfl.crm.enums.boss.WorkOrderTypeCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * tb_work_order
 * Created by wangkun23 on 2018/1/17.
 */
@ToString
public class WorkOrder implements Serializable{
    //工单信息

    /**
     * 自增ID
     */
    @Setter
    @Getter
    private Integer id;

    /**
     * 订单号
     */
    @Setter
    @Getter
    private String orderNo;

    /**
     * 工单号
     */
    @Setter
    @Getter
    private String workOrderNo;

    /**
     * 工单类型关联id
     */
    @Setter
    @Getter
    private Integer workOrderTypeId;

    /**
     * 工单类型代码
     */
    @Setter
    @Getter
    private WorkOrderTypeCode workOrderTypeCode;
    /*工单类型名称*/
    private String workOrderTypeCodeName;
    public String getWorkOrderTypeCodeName() {
        if (workOrderTypeCode != null) {
            return workOrderTypeCode.getValue();
        }
        return "";
    }

    /**
     * 发起部门ID
     */
    @Setter
    @Getter
    private Integer createAmibaId;

    /*发起部门名称*/
    @Setter
    @Getter
    private String createAmibaName;

    /*发起人员工code*/
    @Setter
    @Getter
    private String createStaffCode;

    /*发起人*/
    @Setter
    @Getter
    private String createStaffName;

    @Setter
    @Getter
    private String createStaffMobile;

    /*受理部门*/
    @Setter
    @Getter
    private Integer receiveAmibaId;

    /*受理部门名称*/
    @Setter
    @Getter
    private String receiveAmibaName;

    /*分配人code*/
    @Setter
    @Getter
    private String assigneeStaffCode;
    /*分配人*/
    @Setter
    @Getter
    private String assigneeStaffName;

    @Getter
    @Setter
    private String assigneeStaffMobile;

    /*分配时间*/
    @Setter
    @Getter
    private Date assigneeTime;

    /*处理责任人*/
    @Setter
    @Getter
    private String claimStaffCode;
    /*处理责任人*/
    @Setter
    @Getter
    private String claimStaffName;

    @Setter
    @Getter
    private String claimStaffMobile;

    /*完成时间*/
    @Setter
    @Getter
    private Date endTime;

    /*工单状态*/
    @Setter
    @Getter
    private WorkOrderStatus status;

    private String statusName;/*工单名称*/

    public String getStatusName() {
        if(StringUtils.isNotEmpty(statusName)){
            return this.statusName;
        }
        if(Objects.nonNull(status)){
            return status.getKey();
        }
        return "";
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }

    private int statusIndex;

    public int getStatusIndex() {
        if(Objects.nonNull(status)){
            return status.getIndex();
        }
        return 0;
    }

    /*是否是返库工单，默认：N,是：Y*/
    @Setter
    @Getter
    private BackStatus back;

    private String backName;

    public String getBackName() {
        if(Objects.nonNull(back)){
            return back.getKey();
        }
        return StringUtils.EMPTY;
    }

    /*订单状态*/
    @Setter
    @Getter
    private String sourceOrderNo;

    /*工单备注描述*/
    @Setter
    @Getter
    private String remark;

    /*创建人*/
    @Setter
    @Getter
    private String createdBy;

    /*创建时间*/
    @Setter
    @Getter
    private Date createdTime;

    /*更新时间*/
    @Setter
    @Getter
    private Date modifiedTime;

    //以下是订单信息

    /*客户姓名*/
    @Setter
    @Getter
    private String name;

    /*客户手机号*/
    @Setter
    @Getter
    private String mobile;


    /*商务经理手机号*/
    @Setter
    @Getter
    private String businessManagerMobile;


    /*交付经理经理手机号*/
    @Setter
    @Getter
    private String deliverManagerMobile;

    @Setter
    @Getter
    private Integer businessManagerAmibaId;
    @Setter
    @Getter
    private String businessManagerAmibaName;
    @Setter
    @Getter
    private Integer deliverManagerAmibaId;
    /*商务经理*/
    @Setter
    @Getter
    private String businessManager;


    /*交付经理的StaffCode*/
    @Setter
    @Getter
    private String deliverManagerStaffCode;


    /*商务经理的StaffCode*/
    @Setter
    @Getter
    private String businessManagerStaffCode;

    /*交付经理*/
    @Setter
    @Getter
    private String deliverManager;

    /*订单渠道名称*/
    @Setter
    @Getter
    private String channelName;

    /*借款金额*/
    @Setter
    @Getter
    private BigDecimal loanAmount;

    /*贷款利率*/
    @Setter
    @Getter
    private BigDecimal rate;

    /*总服务费率*/
    @Setter
    @Getter
    private BigDecimal totalFeeRate;

    /*服务费金额*/
    @Setter
    @Getter
    private BigDecimal serviceAmount;

    /*渠道佣金费率*/
    @Setter
    @Getter
    private BigDecimal channelRate;

    /*渠道佣金金额*/
    @Setter
    @Getter
    private BigDecimal channelFee;

    /*报单时间*/
    @Setter
    @Getter
    private Date submitTime;

    /*评分*/
    @Setter
    @Getter
    private Integer grade;

    /*订单状态*/
    @Setter
    @Getter
    private OrderStatus orderStatus;

    /*订单状态名称*/
    @Setter
    @Getter
    private String orderStatusName;

    public String getOrderStatusName() {
        if (orderStatus != null) {
            return orderStatus.getValue();
        }
        return "";
    }

    /*微信端标识*/
    @Setter
    @Getter
    private String className;
}